﻿@page "/employee/add"
@page "/employee/edit/{empID:int}"
@inherits AddEditEmployeeModel

<h1>@Title Employee</h1>
<hr />

<EditForm Model="@emp" OnValidSubmit="SaveEmployee">
    <DataAnnotationsValidator />
    <div class="form-group row">
        <label class="control-label col-md-12">Name</label>
        <div class="col-md-4">
            <InputText class="form-control" @bind-Value="emp.Name" />
        </div>
        <ValidationMessage For="@(() => emp.Name)" />
    </div>
    <div class="form-group row">
        <label class="control-label col-md-12">Gender</label>
        <div class="col-md-4">
            <InputSelect class="form-control" @bind-Value="emp.Gender">
                <option value="">-- Select Gender --</option>
                <option value="Male">Male</option>
                <option value="Female">Female</option>
            </InputSelect>
        </div>
        <ValidationMessage For="@(() => emp.Gender)" />
    </div>
    <div class="form-group row">
        <label class="control-label col-md-12">Designation</label>
        <div class="col-md-4">
            <InputText class="form-control" @bind-Value="emp.Department" />
        </div>
        <ValidationMessage For="@(() => emp.Department)" />
    </div>
    <div class="form-group row">
        <label class="control-label col-md-12">City</label>
        <div class="col-md-4">
            <InputSelect class="form-control" @bind-Value="emp.City">
                <option value="-- Select City --">-- Select City --</option>
                @foreach (var city in cityList)
                {
                    <option value="@city.CityName">@city.CityName</option>
                }
            </InputSelect>
        </div>
        <ValidationMessage For="@(() => emp.City)" />
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary">Save</button>
        <button class="btn btn-light" @onclick="Cancel">Cancel</button>
    </div>
</EditForm>
